let http = require("http");
const { readFile, fstat } = require("fs");


let server = http.createServer();
server.listen(8080);
server.on('request', function(req, res) {
    let url = req.url;
    if(url.lastIndexOf('.') > -1) {
        console.log(url);
        let path = '.' + url;
        readFileByPromise(path, res);
    } else {
        res.end();
    }
});

let promise = function(filename){
    return new Promise(function(resolve, reject) {
        fstat.exists(filename, function(resolve, reject) {
            
        })
    })
}